/* \brief Shareware expiration class

\author : Nish, nishforever@vsnl.com
*/

#ifdef _PGL_SHAREWARE
#pragma once

class CExpire  
{
public:
	enum ETypes
	{
		TypeRun=1,
		TypeDay=2
	};

	size_t GetDaysLeft();
	size_t GetRunsLeft();
	bool HasExpired();

	CExpire(const char*  ProgName,const char* KeyName, size_t Num, ETypes ExpireType);
	virtual ~CExpire();
private:

	bool CreateProtectFile();
	bool m_filefound;
	bool LocateFile();
	char m_systemfolder[MAX_PATH];
	char m_filename[MAX_PATH];
	bool DeObfuscate(char *str, size_t& num);
	bool Obfuscate(size_t num, char *str);	
	bool GetRunCount(size_t& count);
	bool SetRunCount();
	bool SetRunCount(size_t count);
	bool GetDayCount(size_t& count);
	bool SetDayCount();
	bool CreateProgKey(const char*  ProgName, const char* KeyName);
	size_t m_ExpireType;
	size_t m_count;
	HKEY m_hKey;
	bool m_first;
};

#endif